/**
 * 创建3D罗盘
 * @private
 */
export function _createControlBar(map){
    // 添加 3D 罗盘控制
    AMap.plugin(['AMap.ControlBar'], ()=>{
        map.addControl(new AMap.ControlBar({
            position: {
                right: '200px',
                top: '20px'
            },
            showControlButton: true,  // 是否显示倾斜、旋转按钮。默认为 true
        }));
    });
}

/**
 * 绘制行政区域
 * @param map
 * @param city
 * @private
 */
export function _createArea(map,city){
    AMap.plugin(["AMap.DistrictSearch"], () => {
        // 行政区查询服务
        var district = new AMap.DistrictSearch({
            subdistrict: 0,
            extensions: "all",
            level: "city",

        });

        //绘制地图，只显示当前行政区域，自定义边境颜色
        district.search(city, (status, result) => {
            // 外多边形坐标数组和内多边形坐标数组
            var outer = [
                new AMap.LngLat(-360, 90, true),
                new AMap.LngLat(-360, -90, true),
                new AMap.LngLat(360, -90, true),
                new AMap.LngLat(360, 90, true),
            ];
            var holes = result.districtList[0].boundaries;
            var pathArray = [outer];
            pathArray.push.apply(pathArray, holes);
            var polygon = new AMap.Polygon({
                pathL: pathArray,
                strokeColor: "#0469c1",
                strokeWeight: 1.5,
                fillColor: "#132230",
                fillOpacity: 1,
            });
            polygon.setPath(pathArray);
            map.add(polygon);

        });

    });
}

//打开全屏方法
export function _openFullscreen(element) {
  if (element.requestFullscreen) {
    element.requestFullscreen();
  } else if (element.mozRequestFullScreen) {
    element.mozRequestFullScreen();
  } else if (element.msRequestFullscreen) {
    element.msRequestFullscreen();
  } else if (element.webkitRequestFullscreen) {
    element.webkitRequestFullScreen();
  }
}

//退出全屏方法
export function _exitFullScreen() {
  if (document.exitFullscreen) {
    document.exitFullscreen();
  } else if (document.mozCancelFullScreen) {
    document.mozCancelFullScreen();
  } else if (document.msExitFullscreen) {
    document.msExiFullscreen();
  } else if (document.webkitCancelFullScreen) {
    document.webkitCancelFullScreen();

  } else if (document.webkitExitFullscreen) {
    document.webkitExitFullscreen();
  }
}
